﻿#region Imports
using System;
using System.Globalization;
using System.Windows.Data;
using CommonUtilities.Extensions;
using CommonUtilities.Properties;
#endregion

namespace EntertainmentManager.Converters
{
    public class InvalidDateConverter : IValueConverter
    {
        #region IValueConverter Members
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DateTime dt = DateTime.MinValue;
            string format = "dd MMM yyyy";

            try { dt = (DateTime)value; }
            catch (Exception) { }

            if (!(parameter as string).IsNullOrEmpty()) format = parameter as string;
            return dt == DateTime.MinValue ? Resources.Const_NotAvailable : dt.ToString(format);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
        #endregion
    }
}
